﻿namespace  Codeplex.KinkumaFramework.Interactivity
{
    using System.Windows;
    using Microsoft.Practices.Prism.Interactivity.InteractionRequest;

    /// <summary>
    /// ウィンドウを閉じるアクション
    /// </summary>
    public class WindowCloseAction : DispatcherTriggerAction
    {
        protected override void InvokeAction(InteractionRequestedEventArgs e)
        {
            var arg = e.Context as DialogCloseNotification;
            var window = Window.GetWindow(this.AssociatedObject);
            if (arg != null)
            {
                window.DialogResult = arg.DialogResult;
            }

            window.Close();
        }
    }
}
